//
//  HBNewestRequest.m
//  HeartBeat
//
//  Created by karong on 2023/8/25.
//

#import "HBNewestRequest.h"

@implementation HBNewestRequest
- (void)refreshDataSuccess:(回调一个数组)success failed:(失败回调)failed {
    if (self.loading) {
        return;
    }
    self.loading = YES;
    self.haveMore = YES;
    self.page = 1;
    [HBRequest loadNewestWithKeyPage:self.page success:^(NSArray *array) {
        [self loadSuccess:success withArray:array];
    } failed:^(NSURLResponse * _Nonnull response, NSError * _Nonnull error, id  _Nonnull responseObject) {
        failed(response, error, responseObject);
        self.loading = NO;
    }];
}


- (void)loadMoreDataSuccess:(回调一个数组)success failed:(失败回调)failed {
    if (self.loading && !self.haveMore) {
        return;
    }
    [HBRequest loadNewestWithKeyPage:self.page success:^(NSArray *array) {
        [self loadSuccess:success withArray:array];
    } failed:^(NSURLResponse * _Nonnull response, NSError * _Nonnull error, id  _Nonnull responseObject) {
        failed(response, error, responseObject);
        self.loading = NO;
    }];
}
@end
